/**
  ******************************************************************************
  * @file   main.h
  * @author Administrator
  * @since  2024/7/30
  *
  * @brief  Header file of hardware/peripheral driver for Xxx(Hardware/Simulation-Implemented).
  *
  ******************************************************************************
  */
#ifndef CALCELF_MAIN_H
#define CALCELF_MAIN_H


#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>


#define MEM_REGION_VERSION  "Memory Region(Program Size) 1.0"

#define KB(x)               ((x) / 1024)
#define KB_F(x)             ((float)x / 1024)
#define PERCENT(x, y)       (((float)x / (float)y) * 100)

#define MAP_FILE_OFFSET     (-300)

struct context {
    uint32_t ro_size;       // Total RO  Size (Code + RO Data)
    uint32_t ro_used_size;

    uint32_t rw_size;       // Total RW  Size (RW Data + ZI Data)
    uint32_t rw_used_size;

    uint32_t rom_size;      // Total ROM Size (Code + RO Data + RW Data)
    uint32_t rom_used_size;

    char *map_file;         // Keil uVision .map file.
    char *scatter_file;     // Keil uVision .sct file.

    int (*format)(struct context *ctx);
};

enum ERROR_RET {
    ERROR_OK = 0,
    ERROR_FILE_NOT_FOUND,
    ERROR_SEEK_FAILED,
    ERROR_STR_TO_NUM,
    ERROR_CMD_ARG_NOT_SUPPORT,
    ERROR_FUNCTION_NOT_SUPPORT,
};

#endif //CALCELF_MAIN_H
